package com.zhss.dfs.upgrade;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @description: 全局请请求处理
 * @Author liu Weidong
 * @Email:
 * @Date: 2024/6/2 14:09
 * @Version 1.0
 */
public class NetworkRequestQueue {


    private ConcurrentLinkedQueue<NetworkRequest> requestQueue = new ConcurrentLinkedQueue<>();

    private NetworkRequestQueue(){

    }

    private static volatile NetworkRequestQueue networkRequestQueue;

    public static NetworkRequestQueue get(){
        if (networkRequestQueue == null) {
            synchronized (NetworkRequestQueue.class) {
                if (networkRequestQueue == null) {
                    networkRequestQueue = new NetworkRequestQueue();
                }
            }
        }
        return networkRequestQueue;
    }

    public void offer(NetworkRequest networkRequest) {
        requestQueue.offer(networkRequest);
    }

    public NetworkRequest poll(){
        return requestQueue.poll();
    }
}
